1. Field of Invention
The invention relates generally to computer systems. More particularly, methods and apparatus for providing on-demand network application download and execution capabilities in a distributed computer network are disclosed.
2. Description of Relevant Art
Generally speaking, a browser is an application program that provides a way to look at and interact with all the information on the distributed computer networks such as the Internet. In particular, a Web browser is a client program that uses the Hypertext Transfer Protocol (HTTP) to make requests of Web servers throughout the Internet on behalf of the browser user. Java(trademark), a programming language developed by Sun Microsystems Inc. of Mountain View Calif., is expressly designed for use in the distributed environment of the Internet. It was designed to have the xe2x80x9clook and feelxe2x80x9d of the C++ language, but it is simpler to use than C++ and enforces a completely object-oriented view of programming. In this way, Java is used to create complete applications that can run on a single computer or be distributed among servers and clients in a network.
One of the many advantages of Java is that it can also be used to build small application modules, or applets, for use as part of a Web page. A Java applet is a small program that can be sent along with a Web page to a user that can perform interactive animations, immediate calculations, or other simple tasks without having to send a user request back to the server. As an example, as shown in FIG. 1, a distributed computer system 100 includes a client computer 102 that is coupled to a server (host) computer 104. The computer 102 includes a browser application 106 that, in turn, includes a requested Web page 108 having an applet 110 embedded therein capable of performing various tasks. In most situations, the applet 110 is executed by a Java Virtual Machine (JVM) 112 that in this example is also resident in the browser 106.
In order for the JVM 112 to execute the applet 110, the applet""s requisite component files (such as xe2x80x9c.class filesxe2x80x9d, images and sounds) represented by files 114-118 must be downloaded from the server 104 to the JVM 112. Typically the server 104 is part of a distributed network of computers, such as the Internet, or in some cases could be part of an intranet type of arrangement. In any case, the files 114-118 that are required for the JVM 112 to run the applet 110 include Java class files as well as resource files that are used to support the execution of the applet 110. Such class files, includes a main class file, main.class 114, that is used by the JVM 112 as an entry point for execution of the applet 110. The server 104 also stores other class files such as b.class 116 that are used by the JVM 112 in the furtherance of executing the applet 110. Various image and sound components used in the execution of the applet 110 are stored in resource files such as c.image 118.
In order for the JVM 112 to execute the applet 110, it may be required to download some of the class and resource files as needed. This is typically accomplished by sending a file request that takes the form of an http request to the server 104 which responds by providing an http response that includes the URL of the requested file. By way of example, the JVM 112 issues a request to retrieve the main class file main.class 114 to which the server 104 responds by sending (i.e., downloading) the requested file (i.e., main.class 114). This request/response procedure is followed for every file for which the JVM 112 requires to execute the applet 110.
This arrangement, though inefficient, is satisfactory for executing most small applets on small, local networks. However as the complexity of the applet increases (thereby increasing both the size and the number of requested files), the performance of the JVM 112 is substantially degraded since the time required to satisfy the increasingly voluminous requests for the increasingly larger files in an increasingly more complex network of computers becomes excessive.
With the introduction of what is referred to as a Java Archive (JAR) file, the performance of network Java applications, such as applets, is somewhat improved. A JAR (Java Archive) file has a platform-independent file format that aggregates many files into one. In those applications using JAR files, multiple Java applets and their requisite components (.class files, images and sounds, etc.) can be bundled in a JAR file and subsequently downloaded to a browser in a single HTTP transaction thereby greatly improving the download speed. In addition, the JAR format also supports compression, which reduces the file size, further improving the download time. For example, referring to FIG. 2, the applet component files 114-118 are stored in a single JAR file 120. Using this arrangement, in order for the JVM 112 to execute the applet 110, only a single HTTP file request 122 is required to download the compressed JAR file 120 that contains all the applet component files 114-118.
When an applet includes multiple JAR files, a class loader will construct an internal search path of JAR files and whenever it tries to load a class or resource file, it would linearly search each JAR file on its search path in the process downloading and opening each of them. If the class loader tries to find a resource file that does not exist at all, then all the JAR files will be downloaded, even if most of them are not needed for the applet to run.
Therefore, what is desired are a method and an apparatus for providing efficient on-demand downloading of files in a distributed network environment.
In one embodiment of the present invention, a method for executing an applet is disclosed. A file download request for a root file is provided to a particular server computer by a virtual machine that is used to execute the applet. The requested root file includes applet component files used by the virtual machine to execute the applet such that related ones of the component files are grouped into a corresponding package. The root file includes an index file that contains information that relates the mapping of the package to corresponding related applet component files. A HASH table based upon the contents of the index file is then created that provides a mapping of all packages and all corresponding component files that are used by the virtual machine to execute the applet. During virtual machine runtime, the HASH table is queried for a location of a particular applet component file after which the particular applet component file is directly downloaded to the virtual machine.
In another embodiment of the invention, an apparatus for executing an applet embedded in a browser is described. The apparatus includes a means for providing a file download request for a root file to a particular server computer by a virtual machine that is used to execute the applet that includes applet component files. Related ones of the component files are grouped into a corresponding package. The apparatus also includes a means for determining if the root file includes an index file that contains information that relates the mapping of the package to corresponding related applet component files and a means for creating a HASH table based upon the contents of the index file that provides a mapping of all packages and all corresponding component files that are used by the virtual machine to execute the applet. The apparatus also includes a means for querying the HASH table for a location of a particular applet component file during virtual machine runtime as well as a means for directly downloading the particular applet component file based upon the location provided by the HASH table to the virtual machine.